{include file="public/header"}
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>任务管理</title>
    <link rel="stylesheet" type="text/css" href="__CSS__/tt.css"/>
    <!--<link rel="stylesheet" href="__JS__/webuploader/webuploader.css" >&lt;!&ndash;webUploader上传组件&ndash;&gt;-->
    <!--<link rel="stylesheet" href="__JS__/webuploader/style.css" >&lt;!&ndash;webUploader上传组件&ndash;&gt;-->
    <link href="/static/admin/css/font-awesome.min.css?v=4.7.0" rel="stylesheet">
    <link href="__JSS__/plugins/layui/css/layui.css" rel="stylesheet">
    <style type="text/css">

        html body {
            margin: 0;
            background-color: #EEEEEE;
            width: 100%;
            height: 100%;
            font-size: 14px;
            color: #333333;
            font-weight: 500;
        }

        .flex-wrap {
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        .flex-con {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
        }

        .flex-vertical {
            -webkit-box-horizontal: vertical;
            -webkit-flex-flow: column;
            flex-flow: column;
        }

        .wrap1 {
            width: 100%;
            background: #3F3F3F;
            height: 30px;
            line-height: 30px;
        }

        .wrap1 .content1 {
            margin: 0 auto;
            width: 1200px;
            font-size: 12px;
            color: #ffffff;
            /*position: relative;*/
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        .kong {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
        }

        .content12 {
            position: relative;
        }

        .redhot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: #BA0000;
            position: absolute;
            left: 24px;
            top: 5px;
        }

        .wrap2 {
            line-height: 60px;
            width: 100%;
            height: 60px;
            background: #ffffff;
        }

        .content2 {
            margin: auto;
            width: 1200px;
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        .content2_left {
            width: 190px;
            font-size: 18px;
            color: #333333;
        }

        .content2_left span {
            display: inline-block;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: #0065F0;
            vertical-align: middle;
            margin-right: 11px;
        }

        .content_middle {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
            text-align: left;
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;

        }

        .content_right {
            font-size: 16px;
        }

        .content_right img {
            display: inline-block;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            margin-right: 20px;
            vertical-align: middle;
        }

        .content_middle .item {
            width: 152px;
        }

        .content_middle .item.active2 {
            color: #0065F0;
        }

        .wrap3 {
            line-height: 60px;
            width: 100%;
            height: 60px;
            background: #0065F0;
        }

        .content3 {
            margin: auto;
            width: 1200px;
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        .content3-left {
            line-height: 60px;
            color: #ffffff;
            font-size: 16px;
        }

        .wrap4 {
            background: #EEEEEE;
            width: 100%;
            padding-top: 30px;
            padding-bottom: 80px;

        }

        .content4 {
            margin: auto;
            width: 1200px;
            /*display: flex;*/
            background: #ffffff;
            padding-top: 50px;
            /*padding-bottom: 40px;*/
        }

        .item4 {
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            margin-bottom: 30px;
        }

        .item4_left {
            width: 184px;
            text-align: right;
            margin-right: 30px;
        }

        .item4_middle {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
            position: relative;
            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        select {
            margin-right: 20px;
            /*flex:1;*/
            width: 160px;
            outline: none;
        }

        option {
            width: 160px;
            height: 34px;
        }

        .inputrenwu {
            padding-left: 11px;
            box-sizing: border-box;
            display: inline-block !important;
            width: 520px !important;
            height: 34px !important;
            line-height: 34px !important;
            border: 1px solid #CCCCCC !important;
            border-radius: 3px;
            outline: none;
        }

        .item4_middle .upload {
            width: 72px;
            height: 34px;
            padding-left: 40px;
            line-height: 34px;
            border: 1px solid #CCCCCC;
            border-radius: 3px;
            margin-right: 60px;
            color: #CCCCCC;
            position: relative;
        }

        .shangchuan {
            position: absolute;
            left: 15px;
            top: 9px;
            width: 16px;
            height: 16px;
            display: block;
        }

        .item4_middle .upload2 {
            width: 82px;
            height: 34px;
            background: #0065F0;
            line-height: 34px;
            border-radius: 3px;
            padding-right: 15px;
            padding-left: 15px;
            padding-right: 15px:
            margin-right: 60px;
            color: #ffffff;
        }

        .item4_middle .upload img {
            vertical-align: middle;
            display: inline-block;
            width: 16px;
            height: 16px;
            margin-right: 10px;
        }

        .item4_middle .text {
            position: absolute;
            left: 0px;
            top: 42px;
            font-size: 12px;
            color: #CCCCCC;
            line-height: 12px
        }

        .ellipsi1 {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        .lable {
            width: 110px;
        }

        .lable .span1,.lable .span11 {
            display: inline-block;
            width: 14px;
            height: 14px;
            vertical-align: middle;
            margin-right: 11px;
            border: 1px solid #D9D9D9;
            border-radius: 50%;
        }

        .lable .span2 {
            display: inline-block;
            width: 14px;
            height: 14px;
            vertical-align: middle;
            margin-right: 11px;
            border: 1px solid #0065F0;
            border-radius: 50%;
            background-size: 100% 100%;
            background: url(__IMG__/yuanhuan1.png) no-repeat center center;
        }

        .radioched,.radioched2 {
            display: inline-block;
            width: 14px;
            height: 14px;
            vertical-align: middle;
            margin-right: 11px;
        }

        .span2 img {
            width: 14px;
            height: 14px;
        }

        .hidden {
            display: none !important;
        }

        .danwei {
            font-size: 14px;
            color: #333333;
            margin-left: 10px;
        }

        .item4_middle .add {
            width: 102px;
            height: 102px;
            margin-right: 60px;
            position: relative;
        }

        .delete {
            position: absolute;
            bottom: 0;
            width: 100%;
            left: 0;
            height: 24px;
            line-height: 24px;
            text-align: center;
            background: rgba(0, 0, 0, 0.3);
            color: #ffffff;
            font-size: 12px;
        }

        .add img {
            width: 100%;
            height: 100%;
        }

        .startime {
            /*width: 160px;*/
            height: 34px;
            border: 1px solid #CCCCCC;
            border-radius: 3px;
            padding: 0 10px;
            box-sizing: border-box;
            margin-right: 10px;
            color: #333333;
            display: flex;
            position: relative;

            display: -webkit-box;
            display: box;
            display: -webkit-flex;
            display: flex;
        }

        .startime_text {
        }

        .startime_middle {
            flex: 1;
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;

        }

        .jianjie {
            width: 520px;
            /*height: 270px;*/
            height: auto;
            padding: 20px;
            box-sizing: border-box;
            background: rgba(255, 255, 255, 1);
            border-radius: 3px;
            border: 1px solid rgba(204, 204, 204, 1);
        }

        .jianjie img {
            display: block;
            width: 100px;
            height: 100px;
            margin-bottom: 16px;
        }

        .jianjie p {
            font-size: 12px;
            line-height: 18px;
            color: #666666;
        }

        .select {
            margin-right: 20px;
            width: 160px;
            height: 34px;
            border-radius: 3px;
            border: 1px solid #cccccc;
            display: flex;
            padding-left: 10px;
            box-sizing: border-box;
            line-height: 34px;
            color: #666666;
            font-size: 12px;
            position: relative;
        }

        .everyoption {
            text-indent: 10px;
            height: 32px;
            line-height: 32px;
            font-size: 12px;
            color: #999999;
        }

        .everyoption:hover {
            background: #0065F0;
            color: #ffffff;

        }

        .alloption {
            display: none;
            background: #ffffff !important;
            z-index: 999;
            padding-left: 0px;

            box-sizing: border-box;
            position: absolute;
            left: 0;
            top: 36px;
            border: 1px solid #eeeeee;
            height: auto;
            box-shadow: 0px 0px 6px 0px rgba(0, 101, 240, 0.6);
            width: 160px;
            overflow-y: scroll;
            max-height: 256px;
        }

        .select .option {
            flex: 1;
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;

        }

        .sanjiao_wrap {
            border-left: 1px solid #cccccc;

            width: 32px;
            height: 32px;
            position: absolute;
            right: 0px;
            top: 0px;
        }

        .sanjiao2 {

            display: block;
            position: absolute;
            left: 50%;
            top: 50%;
            width: 32px;
            height: 32px;
            transform: translate(-50%, -50%);

            -ms-transform: translate(-50%, -50%);
            -moz-transform: translate(-50%, -50%);
            -webkit-transform: translate(-50%, -50%);
            -o-transform: translate(-50%, -50%);
        }

        .sanjiao1 {
            position: absolute;
            left: 50%;
            top: 50%;
            width: 32px;
            height: 32px;
            transform: translate(-50%, -50%) rotate(180deg);

            -ms-transform: translate(-50%, -50%) rotate(180deg);
            -moz-transform: translate(-50%, -50%) rotate(180deg);
            -webkit-transform: translate(-50%, -50%) rotate(180deg);
            -o-transform: translate(-50%, -50%) rotate(180deg);
        }

        * {
            cursor: pointer;
        }

        .btn1 {
            width: 130px;
            height: 34px;
            background: #0065F0;
            color: #ffffff;
            line-height: 34px;
            text-align: center;
            margin-right: 35px;
            font-size: 12px;

        }

        .btn2 {
            font-size: 12px;
            width: 130px;
            height: 34px;
            background: #F7F7F7;
            color: #D9D9D9;
            line-height: 34px;
            text-align: center;
            margin-right: 35px;
        }
    </style>
    <style>
        .selecttttName1 {
            background: #0065F0;
            color: #ffffff;
        }
        .w-e-text-container{
            height: 300px !important;/*!important是重点，因为原div是行内样式设置的高度500px*/
        }
    </style>
</head>

<body>
<div class="wrap3">
    <div class="content3">
        <div class="content3-left">
            任务管理 > 发布
        </div>
    </div>
</div>
<div class="wrap4">
    <!--<form id="fabutask" action="/shop/Task/test" method="post" enctype="multipart/form-data">-->
    <form id="fabutask">
        <div class="content4">
            <div class="item4">
                <div class="item4_left">
                    任务类型
                </div>
                <div class="item4_middle">
                    <div class="select" onclick="selectclick(1);">
                        <div class="option task_type">请选择类型</div>
                        <div class="sanjiao_wrap">
                            <img class="sanjiao2" src="__IMG__/select.png" id="sanjiao1">
                        </div>
                    </div>
                    <div class="alloption" id="alloption1">
                        <div class="everyoption" value="2">求赞求粉</div>
                        <div class="everyoption" value="3">问卷</div>
                        <div class="everyoption" value="4">投票</div>
                        <div class="everyoption" value="6">分享</div>
                    </div>
                </div>
            </div>
            <div class="item4 task_href">
                <div class="item4_left xiazai">
                    任务链接
                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" name="task_href" type="text" placeholder="请填写带http的链接地址">
                </div>
            </div>
            <!--下载时要填写的：多了仨 start -->

            <!--下载时要填写的：多了仨 end -->
            <div class="item4 hidden input_video">
                <div class="item4_left">
                    上传视频
                </div>
                <div class="item4_middle">
                    <div class="upload">
                        <img src="__IMG__/upload1.png" alt="" class="shangchuan"/> 上传视频
                    </div>
                    <input type="file" accept="video/mp4" id="file" onChange="preview(this)" style="display:none;" name ="input_video" >
                    <!-- <div class="upload2 ellipsi1">
                        已上传的名称少时诵诗书
                    </div> -->
                    <div class="text havevideo">注：请上传15s以上的视频
                    </div>
                </div>
            </div>
            <div class="item4 hidden task_share_type" style="padding-top:15px;">
                <div class="item4_left">
                    分享类型
                </div>
                <div class="item4_middle">
                    <div class="lable" onclick="choosetype(0)">
                        <span class="span1 hidden"></span>
                        <img src="__IMG__/radio.png" class="radioched"> 曝光率

                    </div>
                    <div class="lable" onclick="choosetype(1)">
                        <img src="__IMG__/radio.png" class="radioched hidden">
                        <span class="span1"></span> 到达率
                    </div>
                    <div class="text">注：曝光率是分享次数，到达率是分享出去的
                    </div>
                </div>

            </div>
            <!--曝光率和到达率的二期新增 start-->
            <div class="erqifen hidden">
                <!--是否需要审核-->
                <div class="item4">
                    <div class="item4_left">
                        是否上传图
                    </div>
                    <div class="item4_middle">
                        <div class="lable">
                            <input type="radio" name="task_share_submit" value="1" checked> 是
                        </div>
                    </div>
                </div>
                <!--曝光率：要分享几次-->
                <div class="item4 bao_g" style="padding-top:15px;">
                    <div class="item4_left">
                        分享次数
                    </div>
                    <div class="item4_middle">
                        <input class="inputrenwu" name="task_share_b_num" id="task_share_b_num" type="text" oninput = "handleMoney(this,0);" value="1">
                    </div>
                </div>
                <!--到达率：默认不分步骤1 -->
                <div class="item4 dao_d hidden">
                    <div class="item4_left">
                        是否分步骤
                    </div>
                    <div class="lable">
                        <input type="radio" name="task_share_d_fen" value="1" checked> 不分
                    </div>
                </div>
            </div>
            <!--曝光率和到达率的二期新增  end -->
            <div class="item4">
                <div class="item4_left">
                    任务总数
                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" name="task_num" id="task_num" type="text" value="1" readonly style="width:160px;">
                    <div class="danwei">/个</div>
                </div>
            </div>
            <div class="item4">
                <div class="item4_left">
                    单个任务金额
                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" name="task_price" id="task_price" type="text" oninput = "handleMoney(this,1);" placeholder="最多保留一位小数" style="width:160px;">
                    <div class="danwei">/平台币
                        <span style="margin-left:20px;">任务金额
                   </span>
                    </div>
                    <div class="text">注：1元=10平台币
                    </div>


                </div>
            </div>
            <div class="item4" style="padding-top:15px;">
                <div class="item4_left">
                    任务总金额

                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" type="text" name="money" id="money" value="0" style="width:160px;" readonly>
                    <div class="danwei">/平台币

                    </div>

                </div>
            </div>
            <div class="item4">
                <div class="item4_left">
                    任务名称

                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" maxlength="25" name="task_name" type="text" placeholder="请输入任务名称">
                </div>
            </div>
            <div class="item4" style="height:auto;">
                <div class="item4_left">
                    任务图片
                </div>
                <input type="file" accept="image/*" id="fileimg" onChange="previewimg(this)" style="display:none;" name ="input_image" >
                <div class="item4_middle"  id="uploader"><!--如果不加这个id=uploader下面的王编辑器加载不出来。。。-->
                    <div class="add uploadimg">
                        <img src="__IMG__/addpic.png" alt="">
                    </div>
                    <div class="add imgshow hidden">
                        <img id="imgsrc" src="" alt="">
                        <div class="delete" onclick="delimg();">
                            删除
                        </div>
                    </div>
                </div>
            </div>
            <div class="item4">
                <div class="item4_left">
                    起止时间
                </div>
                <div class="item4_middle">
                    <div class="startime">
                        <input style="border: none" type="text" name="task_starttime" class="startime_text test_item" placeholder="请输入开始时间" readonly />
                    </div>
                    <div>至</div>
                    <div class="startime" style="margin-left:10px;">
                        <input style="border: none" type="text" class="startime_text test_item" name="task_endtime" placeholder="请输入结束时间" readonly />
                    </div>
                </div>
            </div>
            <div class="item4" style="height:auto;">
                <div class="item4_left">
                    任务简介

                </div>
                <div id="LAY_editor" style="width:750px;">
                    <p></p>
                </div>
            </div>
            <div class="item4" style="height:auto;">
                <div class="item4_left">

                </div>
                <div style="width: 750px;height: 20px;line-height: 20px;margin-top: -30px;color: gray;font-size: 13px;">
                    注：分享任务内容插入链接需点击编辑器 <img src="__IMG__/href.png" height="17"> 图标进行插入，建议插入链接名称和链接一致
                </div>
            </div>
            <!--d-->
            <div class="hidden aaa_boss">
                <!--分享途径选择 start -->
                <div class="item4">
                    <div class="item4_left">
                        分享渠道
                    </div>
                    <div class="item4_middle">
                        <input type="checkbox" id="qqqddd1" name="task_share_qudao[]" value="1" /><label for="qqqddd1">&nbsp; 微信 &nbsp;&nbsp;&nbsp;</label>
                        <input type="checkbox" id="qqqddd2" name="task_share_qudao[]" value="2" /><label for="qqqddd2">&nbsp; 朋友圈 &nbsp;&nbsp;&nbsp;</label>
                        <input type="checkbox" id="qqqddd3" name="task_share_qudao[]" value="3" /><label for="qqqddd3">&nbsp; QQ &nbsp;&nbsp;&nbsp;</label>
                        <input type="checkbox" id="qqqddd4" name="task_share_qudao[]" value="4" /><label for="qqqddd4">&nbsp; 微博 &nbsp;&nbsp;&nbsp;</label>
                    </div>
                </div>
                <!--分享途径选择  end -->
            <div class="item4 aaa_type" style="padding-top:15px;">
                <div class="item4_left">
                    分享内容类型
                </div>
                <div class="item4_middle">
                    <div class="lable" onclick="choosetype2(0)">
                        <span class="span11 hidden"></span>
                        <img src="__IMG__/radio.png" class="radioched2"> 编辑器

                    </div>
                    <div class="lable" onclick="choosetype2(1)">
                        <img src="__IMG__/radio.png" class="radioched2 hidden">
                        <span class="span11"></span> 链接
                    </div>
                    <div class="lable" onclick="choosetype2(2)">
                        <img src="__IMG__/radio.png" class="radioched2 hidden">
                        <span class="span11"></span> 图片
                    </div>
                </div>
            </div>
                <div class="item4 sharepic hidden" style="height:auto;">
                    <div class="item4_left">
                        分享的图片
                    </div>
                    <input type="file" accept="image/*" id="fileimg2" onChange="previewimg22(this)" style="display:none;" name ="input_image22" >
                    <div class="item4_middle"  id="uploader2"><!--如果不加这个id=uploader下面的王编辑器加载不出来。。。-->
                        <div class="add uploadimg2">
                            <img src="__IMG__/addpic.png" alt="">
                        </div>
                        <div class="add imgshow2 hidden">
                            <img id="imgsrc2" src="" alt="">
                            <div class="delete" onclick="delimg22();">
                                删除
                            </div>
                        </div>
                    </div>
                </div>
            <div class="item4 aaa_href hidden">
                <div class="item4_left">
                    分享链接
                </div>
                <div class="item4_middle">
                    <input class="inputrenwu" name="task_share_href" type="text" placeholder="请输入分享链接">
                </div>
            </div>
            <!--d-->
            <div class="item4" style="height:auto;margin-bottom:0;" id="forshare">
                <div class="item4_left">
                    任务内容
                </div>
                <div id="LAY_editor2" style="width:750px;">
                    <p></p>
                </div>
            </div>
            </div>
            <div class="item4" style="height:34px;padding:40px 0;margin-bottom:0;">
                <div class="item4_left">

                </div>
                <div class="item4_middle">
                    <div class="btn1">
                        立即发布

                    </div>
                    <div class="btn2" onclick="history.go(-1)">
                        取消
                    </div>
                </div>
            </div>

        </div>
        <input type="hidden" name="task_type" id="task_type" value="" />
        <input type="hidden" name="task_active" id="task_active" value="3" />
        <input type="hidden" name="task_share_type" id="task_share_type" value="1" />
        <input type="hidden" name="task_share_content_type" id="task_share_content_type" value="1" />
        <input type="hidden" name="task_sheng" id="task_sheng" value="" />
        <input type="hidden" name="task_shi" id="task_shi" value="" />
        <input type="hidden" name="task_qu" id="task_qu" value="" />
        <input type="hidden" name="task_image" id="task_image" value="" /><!--为1没传图  为2已传图-->
        <input type="hidden" name="task_image2" id="task_image2" value="" /><!--为1没传图  为2已传图-->
        <input type="hidden" name="task_video" id="task_video" value="" /><!--为1没传图  为2已传图-->
        <!--防止重复提交-->
        <input type="hidden" name="repeatSubmit" id="repeatSubmit" value="1" />
        <!--<input type="submit" value="上传文件">-->
    </form>
</div>
</div>
</body>
{include file="public/footer"}
<script type="text/javascript" src="__JSS__/plugins/layui/layui.all.js"></script>
<script type="text/javascript" src="__JS__/wk.js"></script>
<script type="text/javascript" src="__JS__/webuploader/webuploader.js"></script>
<script src="__JSS__/plugins/wangEditor-3.1.1/release/wangEditor.js" ></script>
<script src="__SCRIPT__/common.js" ></script>
<script>
//    var n = wk.uploads({num:3,type:'jpg,jpeg,png',url:"{:url('shop/upload/uploadLocality')}"});
//    function imgDel(e,obj){
//        wk.uploads_del(e,obj,n,"{:url('shop/upload/deleteLocality')}");
//    }
layui.use('laydate', function () {
    var laydate = layui.laydate;
    //同时绑定多个
    lay('.test_item').each(function(){
        laydate.render({
            elem: this
            ,format:'yyyy-MM-dd HH:mm'
            ,type:'datetime'
            ,trigger: 'click'
        });
    });
    });


    var editor = wk.wang({elem:'#LAY_editor',url:"{:url('shop/upload/wangUpload')}"});
    var editor2 = wk.wang({elem:'#LAY_editor2',url:"{:url('shop/upload/wangUpload')}"});
</script>
<script type="text/javascript">
    //任务类型选择
    $('#alloption1 .everyoption').click(function () {
        var val = $(this).attr('value');
        var text = $(this).text();
        $('#task_type').val(val);
        $('.task_type').text(text);
        if(val == 1){
            $('.task_href_ios,.task_app_ios,.task_app_android').removeClass('hidden');
            $('.xiazai').text('安卓下载链接');
        }else{
            $('.task_href_ios,.task_app_ios,.task_app_android').addClass('hidden');
            $('.xiazai').text('任务链接');
        }
        if(val == 5){
            $('.input_video').removeClass('hidden');
            $('.task_href').addClass('hidden');
        }else{
            $('.input_video').addClass('hidden');
            $('.task_href').removeClass('hidden');
        }
        if(val == 6){
            $('.task_share_type').removeClass('hidden');
            $('.aaa_boss').removeClass('hidden');
            $('.erqifen').removeClass('hidden');
//            $('#forshare').removeClass('hidden');
        }else{
            $('.task_share_type').addClass('hidden');
            $('.aaa_boss').addClass('hidden');
            $('.erqifen').addClass('hidden');
//            $('#forshare').addClass('hidden');
        }
        selectclick(1);
    });
    function selectclick(index) {
        // alert(1);
        if (document.getElementById('alloption' + index).style.display != 'block') {
            document.getElementById('alloption' + index).style.display = 'block';
            document.getElementById('sanjiao' + index).className = 'sanjiao1';
        } else {
            document.getElementById('sanjiao' + index).className = 'sanjiao2';
            document.getElementById('alloption' + index).style.display = 'none';
        }
        if(index == 1 && document.getElementById('alloption' + 7).style.display == 'block'){
            selectclick(7);
        }
    }
    function choosetype(index) {
        var span1 = document.getElementsByClassName('span1');
        var radioched = document.getElementsByClassName('radioched');
        for (var i = 0; i < span1.length; i++) {
            span1[i].className = 'span1';
            radioched[i].className = 'radioched hidden';

        }
        span1[index].className = 'span1 hidden';
        radioched[index].className = 'radioched';
        $('#task_share_type').val(index+1);
        //
        if(index == 1){
            $('.bao_g').addClass('hidden');
            $('.dao_d').removeClass('hidden');
        }else{
            $('.bao_g').removeClass('hidden');
            $('.dao_d').addClass('hidden');
        }
    }
    function choosetype2(index) {
//
        if(index == 0){
            $('#forshare').removeClass('hidden');
            $('.aaa_href').addClass('hidden');
            $('.sharepic').addClass('hidden');
        }else if(index == 1){
            $('.aaa_href').removeClass('hidden');
            $('#forshare').addClass('hidden');
            $('.sharepic').addClass('hidden');
        }else{
            $('.aaa_href').addClass('hidden');
            $('#forshare').addClass('hidden');
            $('.sharepic').removeClass('hidden');

        }
//
        var span1 = document.getElementsByClassName('span11');
        var radioched = document.getElementsByClassName('radioched2');
        for (var i = 0; i < span1.length; i++) {
            span1[i].className = 'span11';
            radioched[i].className = 'radioched2 hidden';

        }
        span1[index].className = 'span11 hidden';
        radioched[index].className = 'radioched2';
        $('#task_share_content_type').val(index+1);
    }
    $('.upload').click(function () {
        $('#file').click();
        $('.havevideo').text('上传中，请稍后...');
    });
    $('.uploadimg').click(function () {
        $('#fileimg').click();
    });
    $('.uploadimg2').click(function () {
        $('#fileimg2').click();
    });
    function preview(obj){

        uploadVideoCommon('fabutask','task_video');
//        $('.havevideo').text(obj.files[0]['name']);

    }
    function previewimg(obj){
        var src = window.URL.createObjectURL(obj.files[0]);
        $('#imgsrc').attr('src',src);
        $('.imgshow').removeClass('hidden');
        uploadImageCommon('fabutask','task_image',0);
    }
    function previewimg22(obj){
        var src = window.URL.createObjectURL(obj.files[0]);
        $('#imgsrc2').attr('src',src);
        $('.imgshow2').removeClass('hidden');
        uploadImageCommon('fabutask','task_image2',1);
    }
    function delimg(){
        $('.imgshow').addClass('hidden');
        $('#task_image').val('');
    }
    function delimg22(){
        $('.imgshow2').addClass('hidden');
        $('#task_image2').val('');
    }
    $('.btn1').click(function () {
//        var formData = new FormData($( "#fabutask" )[0]);//addForm是表单的id，不是input file的
//        formData.append("task_content", editor.txt.html());
//        formData.append("task_share_content", editor2.txt.html());
        var repeatSubmit = $('#repeatSubmit').val();
        if(repeatSubmit == 2){
            alert('请勿重复提交！');
            return false;
        }else{
            var submitInfo = formCheck();
            if(submitInfo.status == 200){
                $('#repeatSubmit').val(2);
                var formData = $( "#fabutask" ).serialize();
                var task_content = editor.txt.html();
                var task_share_content = editor2.txt.html();
                formData += '&task_content='+task_content+'&task_share_content='+task_share_content;
                $.ajax({
                    url: '/shop/Task/releaseDarenTask',
                    data: formData,
                    type: 'POST',
                    dataType: 'JSON',
                    success: function (returnData) {
                        alert(returnData.msg);
                        if(returnData.status == 200){
                            window.location.href = '/shop/Task/homePage';
                            return true;
                        }else{
                            $('#repeatSubmit').val(1);
                        }
                    },
                    error: function () {
                        alert('服务器错误，请刷新重试！');
                    }
                })
            }else{
                alert(submitInfo.msg);
                return false;
            }
        }
    });

</script>
<script>
    function handleMoney(obj,type){
        if(type == 0){
            obj.value = obj.value.replace(/[^\d]/g, '');
            obj.value = obj.value.replace(/\.{2,}/g, '.');
            obj.value = obj.value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
            if (obj.value.indexOf('.') < 0 && obj.value != '') {
                obj.value = parseFloat(obj.value);
            }
            if ((obj.value.length == 1 && obj.value == '.') || obj.value.substring(0,1) == '.') {
                obj.value = '';
            }
        }else{
            obj.value = obj.value.replace(/[^\d.]/g, '');
            obj.value = obj.value.replace(/\.{2,}/g, '.');
            obj.value = obj.value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
//            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d).*$/, '$1$2.$3'); //只能输入1个小数
            if (obj.value.indexOf('.') < 0 && obj.value != '') {
                obj.value = parseFloat(obj.value);
            }
            if ((obj.value.length == 1 && obj.value == '.') || obj.value.substring(0,1) == '.') {
                obj.value = '';
            }
        }

        var value1 = $('#task_num').val();
        var value2 = $('#task_price').val();
        if(value1 && value2){
            var res = value1*value2;
            $('#money').val(res.toFixed(1));
        }else{
            $('#money').val(0);
        }
    }
</script>
<script>
    function formCheck() {
        var res = {
            'status':'200',
            'msg':'OK'
        };
        var task_type = $('input[name="task_type"]').val();
        var task_href = $('input[name="task_href"]').val();
        var task_href_ios = $('input[name="task_href_ios"]').val();
        var task_app_ios = $('input[name="task_app_ios"]').val();
        var task_app_android = $('input[name="task_app_android"]').val();
        var task_num = $('input[name="task_num"]').val();
        var task_price = $('input[name="task_price"]').val();
        var money = $('input[name="money"]').val();
        var task_image = $('input[name="task_image"]').val();
        //分享图片
        var task_image2 = $('input[name="task_image2"]').val();
        //
        var task_video = $('input[name="task_video"]').val();
        var task_name = $('input[name="task_name"]').val();
        var task_share_type = $('input[name="task_share_type"]').val();
        var task_starttime = $('input[name="task_starttime"]').val();
        var task_endtime = $('input[name="task_endtime"]').val();
        var task_content = editor.txt.html();
        var task_share_content = editor2.txt.html();
        if(!task_type){
            res.status = 0;
            res.msg = '任务类型不能为空';
            return res;
        }
        if(task_type != 5 && task_type != 6){
            if(!task_href){
                res.status = 0;
                res.msg = '任务链接不能为空';
                return res;
            }
        }
        if(task_type == 5){
            if(!task_video){
                res.status = 0;
                res.msg = '任务视频不能为空';
                return res;
            }
        }
        if(task_type == 6){
            var task_share_content_type = $('input[name="task_share_content_type"]').val();
            var task_share_href = $('input[name="task_share_href"]').val().trim();
            if(task_share_content_type == 1){
                if(task_share_content == '<p><br></p>' || task_share_content == '<p></p><p><br></p>'){
                    res.status = 0;
                    res.msg = '分享任务的内容不能为空';
                    return res;
                }
            }else if(task_share_content_type == 2){
                if (task_share_href == '') {
                    res.status = 0;
                    res.msg = '分享任务的分享链接不能为空';
                    return res;
                }
            }else{
                if(!task_image2){
                    res.status = 0;
                    res.msg = '分享任务的分享图片不能为空';
                    return res;
                }
            }
            //分享渠道
            var qudao = $('input[name="task_share_qudao[]"]:checked').val();
            if(qudao == 'undefined' || !qudao){
                res.status = 0;
                res.msg = '分享任务的分享渠道不能为空';
                return res;
            }
        }
        if (task_type == 1) {
            if (!task_href_ios || !task_app_ios || !task_app_android) {
                res.status = 0;
                res.msg = '任务各下载链接不能为空';
                return res;
            }
        }

        if(!task_num){
            res.status = 0;
            res.msg = '任务总数不能为空';
            return res;
        }
        if(!task_price){
            res.status = 0;
            res.msg = '任务单个金额不能为空';
            return res;
        }
        if(!task_name){
            res.status = 0;
            res.msg = '任务名称不能为空';
            return res;
        }
        if(!task_image){
            res.status = 0;
            res.msg = '任务图片不能为空';
            return res;
        }
        if(!task_starttime || !task_endtime){
            res.status = 0;
            res.msg = '任务开始时间或结束时间不能为空';
            return res;
        }else{
            var today = Date.parse(new Date())/1000;
            var begin = datetime_to_unix(task_starttime+':00');
            var end = datetime_to_unix(task_endtime+':00');
            if(begin <= today){
                res.status = 0;
                res.msg = '任务开始时间不能小于当前时间';
                return res;
            }
            var cb = (end - begin)/3600;
            if(cb < 48){
                res.status = 0;
                res.msg = '任务开始时间不能大于结束时间且相隔不能低于48小时';
                return res;
            }
        }
        if(task_content == '<p><br></p>' || task_content == '<p></p><p><br></p>'){
            res.status = 0;
            res.msg = '任务简介不能为空';
            return res;
        }
        return res;
    }
    function datetime_to_unix(datetime){
        var tmp_datetime = datetime.replace(/:/g,'-');
        tmp_datetime = tmp_datetime.replace(/ /g,'-');
        var arr = tmp_datetime.split("-");
        var now = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5]));
        return parseInt(now.getTime()/1000);
    }
</script>